{{--/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/3/2 8:33
 * Desc:
 */--}}
@extends("layout.admin")

@section("title")
    系统设置
@endsection

@section("content")
    <style>
        .input-width {
            width: 32%;
        }
    </style>
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li><a href="{{route('admin.set.index')}}">基础设置</a></li>
            <li><a href="{{route('admin.set.index.attach.1')}}">顶部导航</a></li>
            <li class="layui-this"><a href="{{route('admin.set.index.attach.2')}}">用户设置</a></li>
            <li><a href="{{route('admin.set.index.attach.3')}}">微信设置</a></li>
            <li><a href="{{route('admin.set.index.attach.4')}}">企业微信设置</a></li>
            <li><a href="{{route('admin.set.index.attach.5')}}">钉钉设置</a></li>
            <li>云存储(暂缓)</li>
        </ul>
        <div class="layui-tab-content" style="height: auto;">
            {{--用户设置--}}
            <div class="layui-tab-item layui-show">
                <form class="layui-form" action="" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">失败次数</label>
                        <div class="layui-input-block">
                            <input type="number" name="locked_num" lay-verify="required" autocomplete="off"
                                   placeholder="登录失败多少次，用户被锁定" class="layui-input input-width"
                                   @if($error==0) value="{{$set["value"]["locked_num"]}}" @endif>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">单一登录</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_only" value="ON" title="开启"
                                   @if($error==0) @if($set["value"]['is_only']==1) checked @endif @endif>
                            <input type="radio" name="is_only" value="OFF" title="关闭"
                                   @if($error==0) @if($set["value"]['is_only']==0) checked @endif @endif>
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            开启后用户只能在一个地方登录
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">开放注册</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_open" value="YES" title="YES"
                                   @if($error==0) @if($set["value"]['is_open']==1) checked @endif @endif>
                            <input type="radio" name="is_open" value="NO" title="NO"
                                   @if($error==0) @if($set["value"]['is_open']==0) checked @endif @endif>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" id="sub" class="layui-btn" data-name="auth" lay-submit="">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection

@section("script")
    <script>
        layui.use(['element', 'form', 'upload'], function () {
            var $ = layui.jquery;
            //登录设置
            $("#sub").click(function (data) {
                const name = data.currentTarget.dataset.name;
                const value = {
                    "locked_num": $("input[name='locked_num']").val(),
                    "is_only": $("input[name='is_only']:checked").val()=="ON"?1:0,
                    "is_open": $("input[name='is_open']:checked").val()=="YES"?1:0,
                };
                admin.set("{{route('admin.set.create')}}", "{{csrf_token()}}", name, value);
            });
        });
    </script>
@endsection

